package astoliarskyi.wicket.card.restriction;

import astoliarskyi.wicket.card.restriction.Term;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class Days10Term extends Term {
	
	private final static int DAYS_NUMBER = 10;
	
	private final Calendar validStartDay;
	private final Calendar validEndDay;

	public Days10Term(Calendar startDay) {
		super(Term.TermType.DAYS10);
		validStartDay = new GregorianCalendar();
		validStartDay.set(Calendar.DAY_OF_MONTH, startDay.get(Calendar.DAY_OF_MONTH));
		validStartDay.set(Calendar.MONTH, startDay.get(Calendar.MONTH));
		validStartDay.set(Calendar.YEAR, startDay.get(Calendar.YEAR));
		
		validEndDay = (GregorianCalendar) validStartDay.clone();
		
		validEndDay.add(Calendar.DAY_OF_MONTH, DAYS_NUMBER-1);

	}
	
	@Override
	public boolean checkout(Calendar dateToday) {
		boolean isValid = validStartDay.compareTo(dateToday) <= 0 &&
			validEndDay.compareTo(dateToday) >= 0;
		return isValid;
	}
	
}
